package mx.com.mindbits.bandpay.utils;


import mx.com.mindbits.bandpay.R;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;

public class CardDataHelp {
	private Context context;
	private TextView tvTitle;
	private TextView tvMessage;
	private ImageView ivImage;
	private LayoutInflater layoutInflater;
	private View view;
	private EditText tvCVV2;
	private AlertDialog.Builder insertCVV2Dialog;	
	private String CVV2;
	
	
	public String getCVV2() {
		return CVV2;
	}

	public void setCVV2(String cVV2) {
		CVV2 = cVV2;
	}

	public CardDataHelp(Context context){
		
		this.context = context;
		
	}
	
	public  AlertDialog insertDeviceHelp(String title, String message, int res ){

		layoutInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		view = layoutInflater.inflate(R.layout.custom_alert_dialog_image, null);

		tvTitle = (TextView) view.findViewById(R.id.titleAlertText);
		tvMessage = (TextView) view.findViewById(R.id.messageText);
		ivImage = (ImageView) view.findViewById(R.id.imageDialog1);
		tvTitle.setText(title);
		tvMessage.setText(message);
		ivImage.setImageResource(res);
		
		AlertDialog helpInsertDevice = new AlertDialog.Builder(context).create();
		//helpInsertDevice.create();
		helpInsertDevice.setCancelable(false);
		helpInsertDevice.setView(view);
		return helpInsertDevice;
	}
	
	
	public AlertDialog.Builder insertCVV2Help(String title, String message){

		layoutInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		view = layoutInflater.inflate(R.layout.custom_alert_dialog_cvv2, null);

		tvTitle = (TextView) view.findViewById(R.id.titleAlertText);
		tvMessage = (TextView) view.findViewById(R.id.messageText);
		ivImage = (ImageView) view.findViewById(R.id.imageDialog1);
		tvTitle.setText(title);
		tvMessage.setText(title);
		ivImage.setImageResource(R.drawable.cvv2_tiny);
		
		tvCVV2 = (EditText) view.findViewById(R.id.cvv2Capture);
		tvCVV2.setText("");
		
		insertCVV2Dialog = new AlertDialog.Builder(context);
		
		insertCVV2Dialog.setPositiveButton(android.R.string.ok, new OnClickListener(){

			@Override
			public void onClick(DialogInterface arg0, int arg1) {
			// TODO Auto-generated method stub
				setCVV2(tvCVV2.getText().toString());
				Log.i(ConstantsValues.TAG_READER, "cvv---2: {" + getCVV2()+"}");
				
			}
		
		});	
			
		
		insertCVV2Dialog.setNegativeButton(android.R.string.cancel, new OnClickListener(){

			@Override
			public void onClick(DialogInterface arg0, int arg1) {
				// TODO Auto-generated method stub
				
			}
			
		});
		
		insertCVV2Dialog.setView(view);
		
		insertCVV2Dialog.create();
		return insertCVV2Dialog;
	}
	
	
	
}
